const express=require('express')
const morgan=require('morgan')
const cors=require('cors')
const router=require('./router')
const error=require('./middleware/error.js')
require('./model')
const app=express()
//配置中间件
app.use(morgan('dev'))
app.use(cors())
app.use(express.json())
// app.use(express.urlencoded())
//配置中间件
const PORT=process.env.PORT || 3000
 app.use('/api',router)
//挂载错误中间件
 app.use(error())
app.listen(PORT,()=>{
    console.log(`server run at localhost:${PORT}`);
})
 console.log(error());